package com.cn.wanxi.servlet.message;

        import com.alibaba.fastjson.JSONObject;
        import com.cn.wanxi.model.MessageModel;
        import com.cn.wanxi.service.IMessageService;
        import com.cn.wanxi.service.impl.MessageServiceImpl;

        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.IOException;

@WebServlet("/adding")
public class MessageAddServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userName = req.getParameter("userName");
        String messageName = req.getParameter("messageName");
        String email = req.getParameter("email");
        String content = req.getParameter("content");
        String view = req.getParameter("view");
        String time = req.getParameter("time");

        MessageModel messageModel = new MessageModel();
        messageModel.setUserName(userName);
        messageModel.setMessageName(messageName);
        messageModel.setEmail(email);
        messageModel.setContent(content);
        messageModel.setView(view);
        messageModel.setTime(time);

        IMessageService iMessageService = new MessageServiceImpl();

        String result = iMessageService.Adding(messageModel);
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("result",result);
        resp.getWriter().println(jsonObject);
    }
}
